<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="UTF-8">
	<title>红酒会 - 智能红酒管家</title>
	<link rel="shortcut icon" type="image/x-icon" href="${ctx}/favicon.ico" />
	<link type="text/css" rel="stylesheet" href="${ctx}/static/styles/bootstrap.min.css" />
</head>
<body>
	
	<c:import url="/header"><c:param name="module">vintry</c:param></c:import>
	<c:import url="/vintry/menu"><c:param name="menu">2</c:param></c:import>
	<c:import url="/talk/right" />
	
	<div class="outWrap">
		<div class="allnewBoxIn">
	    	<div class="allnew_Head">
    			<form action="${ctx}/vintry" method="post">
                	<button id="export" type="button" class="dc_btn"></button>
                	<input type="hidden" id="index" name="index" value="${index}" />
                	<input type="hidden" id="sortType" name="sortType" value="${sortType}" />
                	<input type="hidden" id="sortField" name="sortField" value="${sortField}" />
                </form>
	    	</div>
	        <div style="min-height:620px;">
	        	<table class="table table-bordered table-hover table-striped">
	        		<thead>
		        		<tr>
		        			<th>红酒名称</th>
			              	<th>国家</th>
			              	<th>年份</th>
			              	<th>容量</th>
			              	<th>数量
			              		<c:choose>
			              			<c:when test="${sortField == 'total'}">
			              				<c:if test="${sortType == 0}">
			              					<span class="asc" onclick="changeSort(1, 'total')"></span></c:if>
			              				<c:if test="${sortType == 1}">
											<span class="desc" onclick="changeSort(0, 'total')"></span></c:if>
			              			</c:when>
			              			<c:otherwise><span class="none" onclick="changeSort(1, 'total')"></span></c:otherwise>
			              		</c:choose>
			              	</th>
			              	<th>购买价格
			              		<c:choose>
			              			<c:when test="${sortField == 'price'}">
			              				<c:if test="${sortType == 0}">
			              					<span class="asc" onclick="changeSort(1, 'price')"></span></c:if>
			              				<c:if test="${sortType == 1}">
											<span class="desc" onclick="changeSort(0, 'price')"></span></c:if>
			              			</c:when>
			              			<c:otherwise><span class="none" onclick="changeSort(1, 'price')"></span></c:otherwise>
			              		</c:choose>
			              	</th>
		        		</tr>
	        		</thead>
	        		<tbody>
		        		<c:forEach var="list" items="${page.content}">
	              			<tr>
								<td>
									<a href="${ctx}/vintry/detail/vintry/${list.id}">
										<c:choose>
											<c:when test="${not empty list.wine.chName}">
												${list.wine.chName}
											</c:when>
											<c:otherwise>${list.wine.enName}</c:otherwise>
										</c:choose>
									</a>
								</td>
								<td>${list.wine.country.name}</td>
						    	<td class="center">${list.wine.vintage}年</td>
						  		<td class="right">${list.wine.capacity}ml</td>
								<td class="right">${list.total}</td>
								<td class="right"><fmt:formatNumber value="${list.price}" pattern="#,###,##0.00"/></td>
							</tr>
						</c:forEach>
					</tbody>
	        	</table>
	        
	            <div class="pageListBox">
	            	<div class="pageList">
	            		<c:choose>
				  			<c:when test="${index == 0}">
				  				<a class="Pre now_A" href="javascript:;">首&nbsp;&nbsp;&nbsp;页</a>
	                			<a class="Pre now_A" href="javascript:;">上一页</a>
				  			</c:when>
				  			<c:otherwise>
				  				<a class="Pre" href="javascript:;" onclick="changePage(0);">首&nbsp;&nbsp;&nbsp;页</a>
	                			<a class="Pre" href="javascript:;" onclick="changePage(${index - 1});">上一页</a>
				  			</c:otherwise>
				  		</c:choose>
				  		<c:choose>
				  			<c:when test="${page.totalPages == 0 or index == page.totalPages - 1}">
				  				<a class="Pre now_A" href="javascript:;">下一页</a>
	                			<a class="Pre now_A" href="javascript:;">尾&nbsp;&nbsp;&nbsp;页</a>
				  			</c:when>
				  			<c:otherwise>
				  				<a class="Pre" href="javascript:;" onclick="changePage(${index + 1})">下一页</a>
	                			<a class="Pre" href="javascript:;" onclick="changePage(${page.totalPages - 1})">尾&nbsp;&nbsp;&nbsp;页</a>
				  			</c:otherwise>
				  		</c:choose>
	                </div>
	            </div>
	        </div>
	    </div>
	</div>

	<c:import url="/WEB-INF/views/footer.jsp" />
	
	<script type="text/javascript">
		$(function() {
			$('#export').click(function() {
				location.href = "${ctx}/vintry/export";
			});
		});
	</script>
</body>
</html>